package start.spring.basic.job.job.jobthread;

import lombok.extern.slf4j.Slf4j;
import start.spring.basic.exception.ExceptionUtil;
import start.spring.basic.job.service.demo.IDemoService;

/**
 * 
 * ****************************************************************************
 * 多线程任务样例线程
 *
 * @author(作者)：xuyongyun	
 * @date(创建日期)：2021年5月7日
 ******************************************************************************
 */
@Slf4j
public class DemoThread extends BaseThread {
	
	/**
	 * 业务处理
	 */
	private IDemoService demoService;
	
	@Override
	public void run() {
		
		String errMsg = "";
		String threadStatus = super.THREAD_STATUS_SUCC;
		
		try {
			//记录线程开始执行
			super.reThreadStart(this.demoService.getDao());
			
			//执行自动任务的业务逻辑
			demoService.queryInterfaceVersionFromApi();
			
		}catch(Exception e) {
			
			errMsg = ExceptionUtil.getExceptionDeteil(e, 0);
			log.error("",e);
			
			threadStatus = super.THREAD_STATUS_FAIL;
		}finally {
			super.reThreadEnd(demoService.getDao(),threadStatus,errMsg);
		}
	}

	public IDemoService getDemoService() {
		return demoService;
	}

	public void setDemoService(IDemoService demoService) {
		this.demoService = demoService;
	}

}
